window.onload = function() {
    var main = document.getElementById("list");
    var parent = main.getElementsByClassName("nav-parent");
    var children = main.getElementsByTagName("ul");
    // var arrli = [];



    for (var i = 0; i < parent.length; i++) {
        parent[i].index = i;
        parent[i].onclick = function() {
            if (this.className == "") {
                children[this.index].style.display = "none";
                this.className = "active";
            } else {
                children[this.index].style.display = "block";
                this.className = "";
            }
        }
    }


}